package com.example.bumenguanli.Mapper;

import com.example.bumenguanli.Unity.Worker;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface WorkerMapper {
    @Insert("INSERT INTO worker(name, classroom, teacher, date) VALUES (#{name}, #{classroom}, #{teacher}, #{date})")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    int insert(Worker worker);

    @Delete("DELETE FROM worker WHERE id = #{id}")
    int delete(Integer id);

    @Update("UPDATE worker SET name = #{name}, classroom = #{classroom}, teacher = #{teacher}, date = #{date} WHERE id = #{id}")
    int update(Worker worker);

    @Select("SELECT id, name, classroom, teacher, date FROM worker WHERE id = #{id}")
    Worker select(Integer id);

    @Select("SELECT * FROM worker ORDER BY date DESC")
    List<Worker> selectAll();
}